package com.badibadi.fragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.annotation.SuppressLint;
import android.app.ListFragment;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import cn.jpush.android.api.m;
//import cn.jpush.android.ui.h;

import com.badibadi.activity.AfterLandingActivity;
import com.badibadi.activity.ClubHomepageActivity;
import com.badibadi.activity.ClubListActivity;
import com.badibadi.activity.NoticeActivity;
import com.badibadi.activity.SeeOtherPeopleSpaceActivity;
import com.badibadi.infos.MailModel;
import com.badibadi.infos.Pre_message_total;
import com.badibadi.infos.Record_Info_Model;
import com.badibadi.infos.Results;
import com.badibadi.mail.MailJumpActivity;
import com.badibadi.mail.MailNozixunfeiActivity;
import com.badibadi.mail.MailSendAMassMailActivity;
import com.badibadi.mytools.CalendarTools;
import com.badibadi.mytools.CommonUtils;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.JSONUtils;
import com.badibadi.mytools.MyThreadTool;
import com.badibadi.mytools.TabHostUtils;
import com.badibadi.mytools.Utils;
import com.badibadi.uniclubber.AcceptClubMailActivity;
import com.badibadi.uniclubber.AcceptHuiYuanMailActivity;
import com.badibadi.uniclubber.R;
import com.libjph.util.StringUtil;
//import com.lidroid.xutils.util.LogUtils;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.view.my_view.XListView;
import com.view.my_view.XListView.IXListViewListener;

//name
public class AfterLandingMyHomePageZhanleiXinFragment extends BaseFragment {// after_landing_zhanleixing_layout
	// 匿名头像地址
	public String nimingHead = Constants.BadiDownImgUrl
			+ "/Public/Uploads/1.png" + Constants.appPhoto4img;
	private TabHost mTabHost;
	private FragmentManager manager;
	// private ZhanNeiXinFrag0 frag0;
	private ZhanNeiXinFrag1 frag1;
	private ZhanNeiXinFrag2 frag2;
	private ZhanNeiXinFrag3 frag3;
	private int add_in = 0;

	private IndexButtonState indexButtonState;
	/**
	 * 修改
	 * */
	NotificationManager nm;
	static final int NOTIFICATION_ID = 0x1234;
	
	// /**
	// * 标记（是否点击了删除按钮）
	// */
	// private boolean Flags = false;

	private boolean isClickIndexButton = false;

	private int pageNum = 8;
	private DisplayImageOptions options;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		manager = getFragmentManager();
		// frag0 = new ZhanNeiXinFrag0();

		options = new DisplayImageOptions.Builder()
				.showStubImage(R.drawable.ic_stub)
				.showImageForEmptyUri(R.drawable.noimage)
				.showImageOnFail(R.drawable.noimage).cacheInMemory()
				.cacheOnDisc().displayer(new RoundedBitmapDisplayer(5)).build();
		/**
		 * 修改
		 * */
		nm = (NotificationManager) getActivity().getSystemService(AfterLandingActivity.NOTIFICATION_SERVICE);

	}

	@Override
	public void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		// 刷新
		if (Constants.is_shuaxin == true) {
			if (add_in == 0) {
				FragmentTransaction transaction = manager.beginTransaction();
				frag1 = new ZhanNeiXinFrag1();
				Bundle bun = new Bundle();
				bun.putString("listType", "usercontact");
				frag1.setArguments(bun);
				transaction.replace(R.id.after_landing_zhanleixing_layout,
						frag1);
				transaction.commit();
				add_in = 0;
				Constants.is_shuaxin = false;
			} else if (add_in == 1) {
				FragmentTransaction transaction = manager.beginTransaction();
				frag2 = new ZhanNeiXinFrag2();
				Bundle bun = new Bundle();
				bun.putString("listType", "clubnotice");
				frag2.setArguments(bun);
				transaction.replace(R.id.after_landing_zhanleixing_layout,
						frag2);
				transaction.commit();

				add_in = 1;
				Constants.is_shuaxin = false;
			} else if (add_in == 2) {
				FragmentTransaction transaction = manager.beginTransaction();
				frag3 = new ZhanNeiXinFrag3();
				Bundle bun = new Bundle();
				bun.putString("listType", "contactclub");
				frag3.setArguments(bun);
				transaction.replace(R.id.after_landing_zhanleixing_layout,
						frag3);
				transaction.commit();
				add_in = 2;
				Constants.is_shuaxin = false;
			}
		}
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(
				R.layout.fragment_after_landing_zhanleixin, null);

		frag1 = new ZhanNeiXinFrag1();
		frag2 = new ZhanNeiXinFrag2();
		frag3 = new ZhanNeiXinFrag3();
		initFragment(view);
		settingTabHost(view);

		return view;
	}

	private void initFragment(View view) {
		FragmentTransaction transaction = manager.beginTransaction();
		frag1 = new ZhanNeiXinFrag1();
		Bundle bun = new Bundle();
		bun.putString("listType", "usercontact");
		frag1.setArguments(bun);
		transaction.replace(R.id.after_landing_zhanleixing_layout, frag1);
		transaction.commit();
		add_in = 0;
	}

	private void settingTabHost(View view) {
		mTabHost = (TabHost) view
				.findViewById(R.id.after_landing_zhanleixin_tabhost);
		mTabHost.setup();
		mTabHost.addTab(mTabHost
				.newTabSpec("after_landing_zhanleixin_tabhost two")
				.setIndicator(
						getResources().getString(R.string.wx_user_lianxi),
						getResources().getDrawable(R.drawable.ic_launcher))
				.setContent(R.id.tab2));
		mTabHost.addTab(mTabHost
				.newTabSpec("after_landing_zhanleixin_tabhost three")
				.setIndicator(
						getResources().getString(R.string.wx_club_tongzhi),
						getResources().getDrawable(R.drawable.ic_launcher))
				.setContent(R.id.tab3));
		mTabHost.addTab(mTabHost
				.newTabSpec("after_landing_zhanleixin_tabhost four")
				.setIndicator(
						getResources().getString(R.string.wx_lianxi_club),
						getResources().getDrawable(R.drawable.ic_launcher))
				.setContent(R.id.tab4));
		try {
			TabHostUtils.SetTabHost(getActivity(), mTabHost);
		} catch (Exception e) {
			// TODO: handle exception
		}

		mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
			@Override
			public void onTabChanged(String arg0) {
				FragmentTransaction transaction = manager.beginTransaction();

				switch (mTabHost.getCurrentTab()) {
				case 0:
					if (add_in != 0) {
						frag1 = new ZhanNeiXinFrag1();
						Bundle bun = new Bundle();
						bun.putString("listType", "usercontact");
						frag1.setArguments(bun);
						transaction.replace(
								R.id.after_landing_zhanleixing_layout, frag1);
						transaction.commit();
						add_in = 0;
					}
					break;
				case 1:
					if (add_in != 1) {
						frag2 = new ZhanNeiXinFrag2();
						Bundle bun = new Bundle();
						bun.putString("listType", "clubnotice");
						frag2.setArguments(bun);
						transaction.replace(
								R.id.after_landing_zhanleixing_layout, frag2);
						transaction.commit();
						add_in = 1;
					}
					break;
				case 2:
					if (add_in != 2) {
						frag3 = new ZhanNeiXinFrag3();
						Bundle bun = new Bundle();
						bun.putString("listType", "contactclub");
						frag3.setArguments(bun);
						transaction.replace(
								R.id.after_landing_zhanleixing_layout, frag3);
						transaction.commit();
						add_in = 2;
					}
					break;
				}
			}
		});

	}

	@Override
	public void onPause() {
		super.onPause();
	}

	// TODO Auto-generated method stub
	/** 第二个fragment 会员联系 */
	@SuppressLint("ValidFragment")
	public class ZhanNeiXinFrag1 extends Fragment implements IXListViewListener {
		protected static final String TAG = "ZhanNeiXinFrag1";
		XListView1Adapter x1Adapter;
		XListView xListView1;

		List<MailModel> mailModels;
		List<MailModel> list;
		int page = 0;
		public String listType;
		int pos_ = -1;// 记录删除的项
		private Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case 1:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_net_error));
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 2:
					Utils.ExitPrgress(getActivity());
					try {
						// initListView();
						mailModels.addAll(list);
						x1Adapter.notifyDataSetChanged();
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 3:
					try {
						Utils.ExitPrgress(getActivity());
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xa10));
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 4:// 系统错误
					try {
						Utils.ExitPrgress(getActivity());
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xb12));
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 5:// 删除站内信成功
					try {
						Utils.ExitPrgress(getActivity());
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_delete_success));
						mailModels.remove(pos_);
						x1Adapter.notifyDataSetInvalidated();
					} catch (Exception e) {
					}
					break;
				case 6:// 删除站内信成功
					try {
						Utils.ExitPrgress(getActivity());
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_delete_false));
					} catch (Exception e) {
					}

					break;
				default:
					break;
				}
			}

		};

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View view = inflater
					.inflate(R.layout.after_landing_friends00, null);

			listType = getArguments().getString("listType");
			InitMyXListView2(view);
			return view;
		}

		public void InitMyXListView2(View view) {
			page = 0;
			xListView1 = (XListView) view
					.findViewById(R.id.after_landing_friends00_xlistView);
			xListView1.setPullLoadEnable(true);
			xListView1.setPullRefreshEnable(true);
			mailModels = new ArrayList<MailModel>();
			x1Adapter = new XListView1Adapter(getActivity(), mailModels);
			xListView1.setAdapter(x1Adapter);
			xListView1.setXListViewListener(this);
			xListView1.startLoadMore();

		}

		protected void onLoad() {
			xListView1.stopRefresh();
			xListView1.stopLoadMore();
			xListView1.setRefreshTime(getResources().getString(
					R.string.wx_ganggang));
		}

		@Override
		public void onRefresh() {
			page = 1;
			mailModels = new ArrayList<MailModel>();
			mail(listType, page);
		}

		@Override
		public void onLoadMore() {
			mail(listType, ++page);
		}

		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stubs
		public class XListView1Adapter extends BaseAdapter {

			Context context;
			List<MailModel> mailModels;

			public XListView1Adapter(Context context, List<MailModel> mailModels) {
				this.context = context;
				this.mailModels = mailModels;
			}

			@Override
			public int getCount() {

				return mailModels.size();
			}

			@Override
			public Object getItem(int position) {
				return null;
			}

			@Override
			public long getItemId(int position) {
				return 0;
			}

			@Override
			public View getView(final int position, View convertView,
					ViewGroup parent) {

				if (indexButtonState != null) {
					isClickIndexButton = indexButtonState
							.indexButtonSelect(isClickIndexButton);
				}
				String rank;
				rank = "";// 用于删除
				boolean isReading = false;// 消息状态(是否读过)
				ViewHolder holder = null;
				if (convertView == null) {
					LayoutInflater inflater = LayoutInflater
							.from(getActivity());
					convertView = inflater.inflate(
							R.layout.fragment_afterlanding_zhanleixin_imp1,
							null);
					holder = new ViewHolder();
					holder.deletebtn = (Button) convertView
							.findViewById(R.id.delete0);
					holder.jmp = (LinearLayout) convertView
							.findViewById(R.id.jmp);
					// 头像
					holder.head = (ImageView) convertView
							.findViewById(R.id.head);
					holder.nickName = (TextView) convertView
							.findViewById(R.id.nickName);
					holder.title = (TextView) convertView
							.findViewById(R.id.title);
					// 咨询或者是好友数据
					holder.zxOrhy = (TextView) convertView
							.findViewById(R.id.zxOrhy);
					holder.time = (TextView) convertView
							.findViewById(R.id.time);
					holder.youjiantou = (ImageView) convertView
							.findViewById(R.id.youjiantou);
					convertView.setTag(holder);
				} else {
					holder = (ViewHolder) convertView.getTag();
				}

				if (mailModels.get(position).getIs_anonymity().equals("0")) {// 是否匿名发送（主要用于“用户联系”和“联系俱乐部”）
																				// 0：否，
																				// 1：
																				// 是

					// 1 登录方为答方(第1种情况)
					if (mailModels.get(position).getCons1().getAsk() != null
							&& mailModels.get(position).getCons1().getAnswer() == null) {
						rank = "answerer";
//						LogUtils.d("运行到了这里，登录方为答方469");
						// 头像
						ImageLoader.getInstance().displayImage(
								Constants.BadiDownImgUrl
										+ "/"
										+ mailModels.get(position).getCons1()
												.getAsk().getHead()
										+ Constants.appPhoto4img, holder.head,
								options);
						holder.head
								.setOnClickListener(new View.OnClickListener() {

									@Override
									public void onClick(View v) {
										// TODO Auto-generated method stub
										Intent intent = new Intent(
												getActivity(),
												SeeOtherPeopleSpaceActivity.class);
										intent.putExtra("friend_id", mailModels
												.get(position).getCons1()
												.getAsk().getId());
										startActivity(intent);
									}
								});
						holder.nickName.setText(""
								+ mailModels.get(position).getCons1().getAsk()
										.getNickName());

						// 多少个好友
						SpannableStringBuilder style = new SpannableStringBuilder(
								mailModels.get(position).getCons1().getAsk()
										.getCommonFriends()
										+ getResources().getString(
												R.string.wx_txt_60));
						// 设置指定位置文字的颜色
						style.setSpan(new ForegroundColorSpan(getActivity()
								.getResources().getColor(R.color.blue)), 0,
								((mailModels.get(position).getCons1().getAsk()
										.getCommonFriends().length())),
								Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
						holder.zxOrhy.setText(style);
						try {
							holder.time
									.setText(""
											+ CalendarTools
													.getTimeChangeToString(
															getActivity(),
															mailModels.get(
																	position)
																	.getTime()));
						} catch (Exception e) {
						}

					}
					// 2登录方为问方
					if (mailModels.get(position).getCons1().getAsk() == null
							&& mailModels.get(position).getCons1().getAnswer() != null) {
						rank = "asker";
//						LogUtils.d("运行到了这里，登录方为答方527");
						try {
							// 头像
							ImageLoader.getInstance().displayImage(
									Constants.BadiDownImgUrl + "/"
											+ Utils.getu_Head(getActivity())
											+ Constants.appPhoto4img,
									holder.head, options);
						} catch (Exception e) {
						}

						holder.head
								.setOnClickListener(new View.OnClickListener() {

									@Override
									public void onClick(View v) {
										// TODO Auto-generated method stub
										// Intent intent=new
										// Intent(getActivity(),AfterLandingActivity.class);
										// startActivity(intent);
									}
								});
						holder.nickName.setText(""
								+ Utils.getu_Name(getActivity()));

						// 咨询谁。。。。。
						SpannableStringBuilder style = new SpannableStringBuilder(
								getResources().getString(
										R.string.wx_zixun_maohao)
										+ mailModels.get(position).getCons1()
												.getAnswer().getNickName());
						// 设置指定位置文字的颜色
						style.setSpan(new ForegroundColorSpan(getActivity()
								.getResources().getColor(R.color.blue)), getResources().getString(
										R.string.wx_zixun_maohao).length(),
								style.length(),
								Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
						holder.zxOrhy.setText(style);

						try {
							holder.time
									.setText(""
											+ CalendarTools
													.getTimeChangeToString(
															getActivity(),
															mailModels.get(
																	position)
																	.getTime()));
						} catch (Exception e) {
						}
					}

				} else if (mailModels.get(position).getIs_anonymity()
						.equals("1")) {
//					LogUtils.d("运行到了这里，登录方为答方580");
					try {
						ImageLoader.getInstance().displayImage(nimingHead,
								holder.head, options);
					} catch (Exception e) {
					}
					holder.head.setOnClickListener(new View.OnClickListener() {

						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub

						}
					});
					// 3当登录用户为答方并且问方匿名时
					if (mailModels.get(position).getCons1().getAsk() != null
							&& mailModels.get(position).getCons1().getAnswer() == null) {
						rank = "answerer";
						holder.nickName.setText(getResources().getString(
								R.string.wx_Anonymous_user));
						// 多少个好友
						SpannableStringBuilder style = new SpannableStringBuilder(
								mailModels.get(position).getCons1().getAsk()
										.getCommonFriends()
										+ getResources().getString(
												R.string.wx_txt_60));
						// 设置指定位置文字的颜色
						style.setSpan(new ForegroundColorSpan(getActivity()
								.getResources().getColor(R.color.blue)), 0,
								((mailModels.get(position).getCons1().getAsk()
										.getCommonFriends().length())),
								Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
						holder.zxOrhy.setText(style);

						holder.time.setText(""
								+ CalendarTools.getTimeChangeToString(
										getActivity(), mailModels.get(position)
												.getTime()));

					}// 当登录方为自己（问方）并且自己匿名时
					else if (mailModels.get(position).getCons1().getAnswer() != null
							&& mailModels.get(position).getCons1().getAsk() == null) {
//						LogUtils.d("运行到了这里，登录方为答方622");
						rank = "asker";
						try {
							// 头像
							ImageLoader.getInstance().displayImage(
									Constants.BadiDownImgUrl + "/"
											+ Utils.getu_Head(getActivity())
											+ Constants.appPhoto4img,
									holder.head, options);
						} catch (Exception e) {
						}

						holder.nickName.setText(""
								+ Utils.getu_Name(getActivity()));

						// 咨询谁。。。。。
						SpannableStringBuilder style = new SpannableStringBuilder(
								getResources().getString(
										R.string.wx_zixun_maohao)
										+ mailModels.get(position).getCons1()
												.getAnswer().getNickName());
//						   
//								+ mailModels.get(position).getCons1()
//										.getAnswer().getNickName());
						// 设置指定位置文字的颜色
						style.setSpan(new ForegroundColorSpan(getActivity()
								.getResources().getColor(R.color.blue)), 3,
								style.length(),
								Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
						holder.zxOrhy.setText(style);
//						   

						try {
							holder.time
									.setText(""
											+ CalendarTools
													.getTimeChangeToString(
															getActivity(),
															mailModels.get(
																	position)
																	.getTime()));
						} catch (Exception e) {
						}
					}
				}
				// 消息是否已经读过了
				if (mailModels.get(position).getStatus().equals("0")) {
					isReading = false;
				} else if (mailModels.get(position).getStatus().equals("1")) {
					isReading = true;

				} else // 当登录方为问方
				if (mailModels.get(position).getCons1().getAsk() == null
						&& mailModels.get(position).getCons1().getAnswer() != null
						&& mailModels.get(position).getStatus().equals("2")) {
					isReading = true;
				} else {
					isReading = false;
				}

				// 内容
				String a = "";
				if (mailModels.get(position).getCons1().getTitle().length() > 12) {
					a = (mailModels.get(position).getCons1().getTitle())
							.substring(0, 12);
				} else {
					a = mailModels.get(position).getCons1().getTitle();
				}

				if (isReading == true) {
					SpannableString msp = new SpannableString(getResources()
							.getString(R.string.wx_zhanneix_maohao) + a);
					msp.setSpan(
							new StyleSpan(android.graphics.Typeface.NORMAL), 0,
							msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 正常
					// activity_mail_content.
					// activity_mail_content.getPaint().setFakeBoldText(true);

					holder.title.setText(msp);
				} else {
					SpannableString msp = new SpannableString(getResources()
							.getString(R.string.wx_zhanneix_maohao) + a);
					msp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
							0, msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 粗体
					// activity_mail_content.
					// activity_mail_content.getPaint().setFakeBoldText(true);

					holder.title.setText(msp);
				}

				// .setText("站内信:" + a);
				// 删除站内信的按钮
				if (isClickIndexButton == true) {
					final String aa = rank;
					holder.deletebtn.setVisibility(View.VISIBLE);
					holder.deletebtn
							.setOnClickListener(new View.OnClickListener() {

								@Override
								public void onClick(View v) {
									pos_ = position;

									delete(Utils.getUid(getActivity()),
											mailModels.get(position).getId(),
											mailModels.get(position).getType(),
											aa, handler);
								}
							});
				} else {
					holder.deletebtn.setVisibility(View.INVISIBLE);
					holder.deletebtn
							.setOnClickListener(new View.OnClickListener() {

								@Override
								public void onClick(View v) {

								}
							});
				}
				// holder.title.setOnClickListener(l);
				// 是否需要咨询费
				if (mailModels.get(position).getCons1().getIs_fee().equals("1")) {
					holder.title.setOnClickListener(new View.OnClickListener() {

						@Override
						public void onClick(View v) {

							Intent intent = new Intent(getActivity(),
									MailJumpActivity.class);
							intent.putExtra("id", mailModels.get(position)
									.getId());
							getActivity().startActivity(intent);
						}
					});
					holder.jmp.setOnClickListener(new View.OnClickListener() {

						@Override
						public void onClick(View v) {

							Intent intent = new Intent(getActivity(),
									MailJumpActivity.class);
							intent.putExtra("id", mailModels.get(position)
									.getId());
							getActivity().startActivity(intent);
						}
					});
				} else {
					holder.title.setOnClickListener(new View.OnClickListener() {

						@Override
						public void onClick(View v) {
							Intent intent = new Intent(getActivity(),
									MailNozixunfeiActivity.class);
							intent.putExtra("id", mailModels.get(position)
									.getId());
							getActivity().startActivity(intent);
						}
					});
					holder.jmp.setOnClickListener(new View.OnClickListener() {

						@Override
						public void onClick(View v) {
							Intent intent = new Intent(getActivity(),
									MailNozixunfeiActivity.class);
							intent.putExtra("id", mailModels.get(position)
									.getId());
							getActivity().startActivity(intent);
						}
					});

				}
				
				
				
//				Intent intent = new Intent(getActivity(),
//						ClubListActivity.class);
//				PendingIntent pi = PendingIntent.getActivity(getActivity(),
//						0, intent, 0);
//				Notification notify = new Notification.Builder(getActivity())
//				// 设置打开该通知，该通知自动消失
//						.setAutoCancel(true)
//						// 设置显示在状态栏的通知提示信息
//						.setTicker("有新消息")
//						// 设置通知的图标
//						.setSmallIcon(R.drawable.ic_launcher)
//						// 设置通知内容的标题
//						.setContentTitle("邀请")
//						// 设置通知内容
//						.setContentText(a)
//						 .setDefaults(Notification.DEFAULT_SOUND
//						 |Notification.DEFAULT_LIGHTS)
//						.setWhen(System.currentTimeMillis())
//						// 设改通知将要启动程序的Intent
//						.setContentIntent(pi).build();
//				// 发送通知
//				nm.notify(NOTIFICATION_ID, notify);

				return convertView;

			}
		}

		/**
		 * 用户显示的站内信列表（必须是自己看自己的）
		 * 
		 * @param $uid
		 *            //登录用户ID 测试uid=1// 这个不用传
		 * @param $listType
		 *            //all:全部 usercontact：用户联系 clubnotice：俱乐部通知
		 *            contactclub：联系俱乐部
		 * @param $page
		 *            ;//第几页
		 * @param $pageNum
		 *            ;//每页显示条数 http://127.0.0.1:8080/badibadi/App/inform/mail
		 */
		public void mail(final String listType, final int page) {
			list = new ArrayList<MailModel>();
			MyThreadTool.fixedThreadPool.execute(new Runnable() {
				@Override
				public void run() {
					Map<String, Object> map = new HashMap<String, Object>();
					map.put("uid", Utils.getUid(getActivity()));
					map.put("listType", listType);
					map.put("page", "" + page);
					map.put("pageNum", "" + pageNum);
					String content = Utils.sendRequest(map, Constants.BadiUrl_1
							+ "inform/mail");
					// String content = Utils.getRequest(Constants.BadiUrl
					// + "record_info?rid=" + rid);
					if (content != null) {
						Results results = Utils.checkResult_NNN(getActivity(),
								content);
						//    ("记录的详细数据是:" + content);
//						   
						if (results != null
								&& !results.getRetmsg().equals("null")
								&& results.isRet()) {
//							   
							try {
								list = JSONUtils.getListByJsonString(
										results.getRetmsg(), MailModel.class);
								handler.sendEmptyMessage(2);
							} catch (Exception e) {
								   
							}
						} else {
							handler.sendEmptyMessage(3);
						}
					} else {

						handler.sendEmptyMessage(1);
					}
				}
			});
		}

	}

	// TODO Auto-generated method stub
	/** 第三个 fragment俱乐部通知 */
	@SuppressLint("ValidFragment")
	public class ZhanNeiXinFrag2 extends Fragment implements IXListViewListener {
		protected static final String TAG = "ZhanNeiXinFrag2";
		XListView1Adapter x1Adapter;
		XListView xListView1;

		List<MailModel> mailModels;
		List<MailModel> list;
		int page = 0;
		public String listType;
		int pos_ = -1;// 记录删除的项
		private Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case 1:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_net_error));
						onLoad();
					} catch (Exception e) {
					}
					break;
				case 2:
					Utils.ExitPrgress(getActivity());
					try {
						// initListView();
						mailModels.addAll(list);
						x1Adapter.notifyDataSetChanged();
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 3:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xa10));
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 4:// 系统错误
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xb12));
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 5:// 删除站内信成功
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_delete_success));
						mailModels.remove(pos_);
						x1Adapter.notifyDataSetInvalidated();
					} catch (Exception e) {
					}
					break;
				case 6:// 删除站内信成功
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_delete_false));
					} catch (Exception e) {
					}
					break;
				default:
					break;
				}
			}

		};

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View view = inflater
					.inflate(R.layout.after_landing_friends00, null);

			listType = getArguments().getString("listType");
			InitMyXListView2(view);
			return view;
		}

		public void InitMyXListView2(View view) {
			page = 0;
			xListView1 = (XListView) view
					.findViewById(R.id.after_landing_friends00_xlistView);
			xListView1.setPullLoadEnable(true);
			xListView1.setPullRefreshEnable(true);
			mailModels = new ArrayList<MailModel>();
			x1Adapter = new XListView1Adapter(getActivity(), mailModels);
			xListView1.setAdapter(x1Adapter);
			xListView1.setXListViewListener(this);
			xListView1.startLoadMore();
		}

		protected void onLoad() {
			xListView1.stopRefresh();
			xListView1.stopLoadMore();
			xListView1.setRefreshTime(getResources().getString(
					R.string.wx_ganggang));
		}

		@Override
		public void onRefresh() {
			page = 1;
			mailModels = new ArrayList<MailModel>();
			mail(listType, page);
		}

		@Override
		public void onLoadMore() {
			mail(listType, ++page);
		}

		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stubs
		public class XListView1Adapter extends BaseAdapter {

			Context context;
			List<MailModel> mailModels;

			public XListView1Adapter(Context context, List<MailModel> mailModels) {
				this.context = context;
				this.mailModels = mailModels;
			}

			@Override
			public int getCount() {

				return mailModels.size();
			}

			@Override
			public Object getItem(int position) {
				return null;
			}

			@Override
			public long getItemId(int position) {
				return 0;
			}

			@Override
			public View getView(final int position, View convertView,
					ViewGroup parent) {
				if (indexButtonState != null) {
					isClickIndexButton = indexButtonState
							.indexButtonSelect(isClickIndexButton);
				}
				final String rank = "";
				boolean isReading = false;
				ViewHolder holder = null;
				if (convertView == null) {
					LayoutInflater inflater = LayoutInflater
							.from(getActivity());
					convertView = inflater.inflate(
							R.layout.fragment_afterlanding_zhanleixin_imp2,
							null);
					holder = new ViewHolder();
					holder.deletebtn = (Button) convertView
							.findViewById(R.id.delete0);
					// 头像
					holder.logo = (ImageView) convertView
							.findViewById(R.id.logo);
					holder.name = (TextView) convertView
							.findViewById(R.id.name);
					holder.title = (TextView) convertView
							.findViewById(R.id.title);
					holder.jmp = (LinearLayout) convertView
							.findViewById(R.id.jmp);
					// 咨询或者是好友数据
					// holder.zxOrhy = (TextView) convertView
					// .findViewById(R.id.zxOrhy);
					holder.time = (TextView) convertView
							.findViewById(R.id.time);
					holder.youjiantou = (ImageView) convertView
							.findViewById(R.id.youjiantou);
					convertView.setTag(holder);
				} else {
					holder = (ViewHolder) convertView.getTag();
				}
				// 详细的箭头
				holder.youjiantou
						.setOnClickListener(new View.OnClickListener() {

							@Override
							public void onClick(View v) {
								Intent intent = new Intent(getActivity(),
										AcceptClubMailActivity.class);
								String zhanneixinId = mailModels.get(position)
										.getId();
								intent.putExtra("zhanneixinId", zhanneixinId);
								intent.putExtra("ClubName",
										mailModels.get(position).getCons2()
												.getClub().getName());
								getActivity().startActivity(intent);
							}
						});
				holder.jmp.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						Intent intent = new Intent(getActivity(),
								AcceptClubMailActivity.class);
						String zhanneixinId = mailModels.get(position).getId();
						intent.putExtra("zhanneixinId", zhanneixinId);
						intent.putExtra("ClubName", mailModels.get(position)
								.getCons2().getClub().getName());
						getActivity().startActivity(intent);
					}
				});

				try {
					holder.time.setText(""
							+ CalendarTools.getTimeChangeToString(
									getActivity(), mailModels.get(position)
											.getTime()));
				} catch (Exception e) {
				}

				// 标签内容
				String a = "";
				if (mailModels.get(position).getCons2().getTitle().length() > 12) {
					a = (mailModels.get(position).getCons2().getTitle())
							.substring(0, 12);
				} else {
					a = mailModels.get(position).getCons2().getTitle();
				}
				// holder.title.setText();
				// 未读
				if (mailModels.get(position).getStatus().equals("0")) {
					SpannableString msp = new SpannableString(getResources()
							.getString(R.string.wx_zhanneix_maohao) + a);
					msp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
							0, msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 粗体
					holder.title.setText(msp);
				} else {
					SpannableString msp = new SpannableString(getResources()
							.getString(R.string.wx_zhanneix_maohao) + a);
					msp.setSpan(
							new StyleSpan(android.graphics.Typeface.NORMAL), 0,
							msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 正常

					holder.title.setText(msp);
				}
				//
				holder.title.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						Intent intent = new Intent(getActivity(),
								AcceptClubMailActivity.class);
						String zhanneixinId = mailModels.get(position).getId();
						intent.putExtra("zhanneixinId", zhanneixinId);
						intent.putExtra("ClubName", mailModels.get(position)
								.getCons2().getClub().getName());
						getActivity().startActivity(intent);
					}
				});
				try {
					// 头像
					ImageLoader.getInstance().displayImage(
							Constants.BadiDownImgUrl
									+ "/"
									+ mailModels.get(position).getCons2()
											.getClub().getLogo()
									+ Constants.appPhoto4img, holder.logo,
							options);
				} catch (Exception e) {
					// TODO: handle exception

				}

				holder.logo.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						if (!StringUtil.isNullOrEmpty(mailModels.get(position)
								.getCons2().getCid())) {
							Intent intent = new Intent(getActivity(),
									ClubHomepageActivity.class);
							intent.putExtra("cid", mailModels.get(position)
									.getCons2().getCid());
							startActivity(intent);
						}

					}
				});

				if (mailModels.get(position).getCons2().getClub() != null) {
					holder.name.setText(""
							+ mailModels.get(position).getCons2().getClub()
									.getName());
				}

				// 删除站内信的按钮
				if (isClickIndexButton == true) {
					holder.deletebtn.setVisibility(View.VISIBLE);
					holder.deletebtn
							.setOnClickListener(new View.OnClickListener() {

								@Override
								public void onClick(View v) {
									pos_ = position;
									delete(Utils.getUid(getActivity()),
											mailModels.get(position).getId(),
											mailModels.get(position).getType(),
											rank, handler);
								}
							});
				} else {
					holder.deletebtn.setVisibility(View.INVISIBLE);
					holder.deletebtn
							.setOnClickListener(new View.OnClickListener() {

								@Override
								public void onClick(View v) {

								}
							});
				}

				return convertView;

			}
		}

		/**
		 * 用户显示的站内信列表（必须是自己看自己的）
		 * 
		 * @param $uid
		 *            //登录用户ID 测试uid=1// 这个不用传
		 * @param $listType
		 *            //all:全部 usercontact：用户联系 clubnotice：俱乐部通知
		 *            contactclub：联系俱乐部
		 * @param $page
		 *            ;//第几页
		 * @param $pageNum
		 *            ;//每页显示条数 http://127.0.0.1:8080/badibadi/App/inform/mail
		 */
		public void mail(final String listType, final int page) {
			list = new ArrayList<MailModel>();
			MyThreadTool.fixedThreadPool.execute(new Runnable() {
				@Override
				public void run() {
					Map<String, Object> map = new HashMap<String, Object>();
					map.put("uid", Utils.getUid(getActivity()));
					map.put("listType", listType);
					map.put("page", "" + page);
					map.put("pageNum", "" + pageNum);
					String content = Utils.sendRequest(map, Constants.BadiUrl_1
							+ "inform/mail");
					// String content = Utils.getRequest(Constants.BadiUrl
					// + "record_info?rid=" + rid);
					if (content != null) {
						Results results = Utils.checkResult_NNN(getActivity(),
								content);
						//    ("记录的详细数据是:" + content);
//						   
						if (results != null
								&& !results.getRetmsg().equals("null")
								&& results.isRet()) {
//							   
							try {
								list = JSONUtils.getListByJsonString(
										results.getRetmsg(), MailModel.class);
								handler.sendEmptyMessage(2);
							} catch (Exception e) {
								   
							}
						} else {
							handler.sendEmptyMessage(3);
						}
					} else {

						handler.sendEmptyMessage(1);
					}
				}
			});
		}

	}

	// TODO Auto-generated method stub
	/** 第四个fragment会员通知 */
	@SuppressLint("ValidFragment")
	public class ZhanNeiXinFrag3 extends Fragment implements IXListViewListener {
		protected static final String TAG = "ZhanNeiXinFrag3";
		XListView1Adapter x1Adapter;
		XListView xListView1;

		List<MailModel> mailModels;
		List<MailModel> list;
		int page = 0;
		public String listType;
		int pos_ = -1;// 记录删除的项
		private Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case 1:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_net_error));
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 2:
					Utils.ExitPrgress(getActivity());
					try {
						// initListView();
						mailModels.addAll(list);
						x1Adapter.notifyDataSetChanged();
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 3:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xa10));
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 4:// 系统错误
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xb12));
						onLoad();
					} catch (Exception e) {
					}

					break;
				case 5:// 删除站内信成功
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_delete_success));
						mailModels.remove(pos_);
						x1Adapter.notifyDataSetInvalidated();
					} catch (Exception e) {
					}
					break;
				case 6:// 删除站内信失败
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_delete_false));
					} catch (Exception e) {
					}

					break;
				default:
					break;
				}
			}

		};

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View view = inflater
					.inflate(R.layout.after_landing_friends00, null);

			listType = getArguments().getString("listType");
			InitMyXListView2(view);
			return view;
		}

		public void InitMyXListView2(View view) {
			page = 0;
			xListView1 = (XListView) view
					.findViewById(R.id.after_landing_friends00_xlistView);
			xListView1.setPullLoadEnable(true);
			xListView1.setPullRefreshEnable(true);
			mailModels = new ArrayList<MailModel>();
			x1Adapter = new XListView1Adapter(getActivity(), mailModels);
			xListView1.setAdapter(x1Adapter);
			xListView1.setXListViewListener(this);
			xListView1.startLoadMore();
		}

		protected void onLoad() {
			xListView1.stopRefresh();
			xListView1.stopLoadMore();
			try {
				xListView1.setRefreshTime(getResources().getString(
						R.string.wx_ganggang));
			} catch (Exception e) {
				// TODO: handle exception
			}

		}

		@Override
		public void onRefresh() {
			page = 1;
			mailModels = new ArrayList<MailModel>();
			mail(listType, page);
		}

		@Override
		public void onLoadMore() {
			mail(listType, ++page);
		}

		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		// TODO Auto-generated method stubs
		public class XListView1Adapter extends BaseAdapter {

			Context context;
			List<MailModel> mailModels;

			public XListView1Adapter(Context context, List<MailModel> mailModels) {
				this.context = context;
				this.mailModels = mailModels;
			}

			@Override
			public int getCount() {

				return mailModels.size();
			}

			@Override
			public Object getItem(int position) {
				return null;
			}

			@Override
			public long getItemId(int position) {
				return 0;
			}

			@Override
			public View getView(final int position, View convertView,
					ViewGroup parent) {
				if (indexButtonState != null) {
					isClickIndexButton = indexButtonState
							.indexButtonSelect(isClickIndexButton);
				}// name
				final String rank = "";
				boolean isReading = false;
				ViewHolder holder = null;
				if (convertView == null) {
					LayoutInflater inflater = LayoutInflater
							.from(getActivity());
					convertView = inflater.inflate(
							R.layout.fragment_afterlanding_zhanleixin_imp3,
							null);
					holder = new ViewHolder();
					holder.deletebtn = (Button) convertView
							.findViewById(R.id.delete0);
					// 头像
					holder.head = (ImageView) convertView
							.findViewById(R.id.head);
					holder.name = (TextView) convertView
							.findViewById(R.id.name);
					holder.nickName = (TextView) convertView
							.findViewById(R.id.nickName);
					holder.title = (TextView) convertView
							.findViewById(R.id.title);
					// 咨询或者是好友数据
					// holder.zxOrhy = (TextView) convertView
					// .findViewById(R.id.zxOrhy);
					holder.time = (TextView) convertView
							.findViewById(R.id.time);
					holder.youjiantou = (ImageView) convertView
							.findViewById(R.id.youjiantou);
					holder.jmp = (LinearLayout) convertView
							.findViewById(R.id.jmp);
					convertView.setTag(holder);
				} else {
					holder = (ViewHolder) convertView.getTag();
				}

				// holder.title.setText(""+mailModels);
				try {
					holder.time.setText(""
							+ CalendarTools.getTimeChangeToString(
									getActivity(), mailModels.get(position)
											.getTime()));
				} catch (Exception e) {
				}

				holder.jmp.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						if (mailModels.get(position).getCons3().getClub() != null) {
							Intent intent = new Intent(getActivity(),
									AcceptHuiYuanMailActivity.class);
							if (mailModels.get(position).getCons3().getUser() != null) {
								intent.putExtra("jijian_UserName", mailModels
										.get(position).getCons3().getUser()
										.getNickName());// 寄件者的名称
							} else {
								intent.putExtra(
										"jijian_UserName",
										getResources().getString(
												R.string.wx_Anonymous_user));// 寄件者的名称
							}

							intent.putExtra("Accept_ClubName", ""
									+ mailModels.get(position).getCons3()
											.getClub().getName());// 收件的俱乐部
							intent.putExtra("zhanneixinId",
									mailModels.get(position).getId());
//							   
//									+ mailModels.get(position).getId());
							getActivity().startActivity(intent);
						} else {
							Utils.showMessage(getActivity(), "club error");
						}

					}
				});
				holder.youjiantou
						.setOnClickListener(new View.OnClickListener() {

							@Override
							public void onClick(View v) {
								Intent intent = new Intent(getActivity(),
										AcceptHuiYuanMailActivity.class);
								if (mailModels.get(position).getCons3()
										.getUser() != null) {
									intent.putExtra("jijian_UserName",
											mailModels.get(position).getCons3()
													.getUser().getNickName());// 寄件者的名称
								} else {
									intent.putExtra(
											"jijian_UserName",
											getResources().getString(
													R.string.wx_Anonymous_user));// 寄件者的名称
								}

								if (mailModels.get(position).getCons3()
										.getClub() != null) {
									intent.putExtra("Accept_ClubName", ""
											+ mailModels.get(position)
													.getCons3().getClub()
													.getName());// 收件的俱乐部
								}

								intent.putExtra("zhanneixinId",
										mailModels.get(position).getId());
//								   
//										+ mailModels.get(position).getId());
								getActivity().startActivity(intent);
							}
						});
				// 1下面的全是内容
				String a = "";
				if (mailModels.get(position).getCons3().getTitle().length() > 12) {
					a = (mailModels.get(position).getCons3().getTitle())
							.substring(0, 12);
				} else {
					a = mailModels.get(position).getCons3().getTitle();
				}
				// holder.title.setText();
				// 未读
				if (mailModels.get(position).getStatus().equals("0")) {
					SpannableString msp = new SpannableString(getResources()
							.getString(R.string.wx_zhanneix_maohao) + a);
					msp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
							0, msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 粗体
					holder.title.setText(msp);
				} else {
					SpannableString msp = new SpannableString(getResources()
							.getString(R.string.wx_zhanneix_maohao) + a);
					msp.setSpan(
							new StyleSpan(android.graphics.Typeface.NORMAL), 0,
							msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 正常

					holder.title.setText(msp);
				}
				holder.title.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						if (mailModels.get(position).getCons3().getClub() != null) {
							Intent intent = new Intent(getActivity(),
									AcceptHuiYuanMailActivity.class);
							if (mailModels.get(position).getCons3().getUser() != null) {
								intent.putExtra("jijian_UserName", mailModels
										.get(position).getCons3().getUser()
										.getNickName());// 寄件者的名称
							} else {
								intent.putExtra(
										"jijian_UserName",
										getResources().getString(
												R.string.wx_Anonymous_user));// 寄件者的名称
							}

							intent.putExtra("Accept_ClubName", ""
									+ mailModels.get(position).getCons3()
											.getClub().getName());// 收件的俱乐部

							intent.putExtra("zhanneixinId",
									mailModels.get(position).getId());
//							   
//									+ mailModels.get(position).getId());
							getActivity().startActivity(intent);
						} else {
							Utils.showMessage(
									context,
									""
											+ context.getResources().getString(
													R.string.wx2_25));
						}

					}
				});
				// 2是否匿名发送
				if (mailModels.get(position).getIs_anonymity().equals("1")) {
					// 头像
					ImageLoader.getInstance().displayImage(nimingHead,
							holder.head, options);
					holder.nickName.setText(getResources().getString(
							R.string.wx_Anonymous_user));
					holder.head.setOnClickListener(new View.OnClickListener() {

						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub

						}
					});
				} else if (mailModels.get(position).getIs_anonymity()
						.equals("0")) {
					// 头像
					ImageLoader.getInstance().displayImage(
							Constants.BadiDownImgUrl
									+ "/"
									+ mailModels.get(position).getCons3()
											.getUser().getHead()
									+ Constants.appPhoto4img, holder.head,
							options);
					holder.head.setOnClickListener(new View.OnClickListener() {

						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
							Intent intent = new Intent(getActivity(),
									SeeOtherPeopleSpaceActivity.class);
							intent.putExtra("friend_id",
									mailModels.get(position).getCons3()
											.getUser().getId());
							startActivity(intent);
						}
					});
					holder.nickName.setText(""
							+ mailModels.get(position).getCons3().getUser()
									.getNickName());
				}
				if (mailModels.get(position).getCons3().getClub() != null) {
					// 俱乐部名称
					holder.name.setText(""
							+ mailModels.get(position).getCons3().getClub()
									.getName());
					if (mailModels.get(position).getCons3().getCid() != null) {
						holder.name
								.setOnClickListener(new View.OnClickListener() {

									@Override
									public void onClick(View v) {
										// TODO Auto-generated method stub
										Intent intent = new Intent(
												getActivity(),
												ClubHomepageActivity.class);
										intent.putExtra("cid",
												mailModels.get(position)
														.getCons3().getCid());
										getActivity().startActivity(intent);
									}
								});
					} else {
						holder.name
								.setOnClickListener(new View.OnClickListener() {

									@Override
									public void onClick(View v) {
										// TODO Auto-generated method stub

									}
								});
					}
				} else {
					holder.name.setText("");
					holder.name.setOnClickListener(new View.OnClickListener() {

						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub

						}
					});
				}

				// // 标签内容
				// String a = "";
				// if (mailModels.get(position).getCons2().getTitle().length() >
				// 6) {
				// a = (mailModels.get(position).getCons2().getTitle())
				// .substring(0, 6);
				// } else {
				// a = mailModels.get(position).getCons2().getTitle();
				// }
				// // holder.title.setText();
				// // 未读
				// if (mailModels.get(position).getStatus().equals("0")) {
				// SpannableString msp = new SpannableString("站内信:" + a);
				// msp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
				// 4, msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 粗体
				// holder.title.setText(msp);
				// } else {
				// SpannableString msp = new SpannableString("站内信:" + a);
				// msp.setSpan(
				// new StyleSpan(android.graphics.Typeface.NORMAL), 4,
				// msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 正常
				//
				// holder.title.setText(msp);
				// }
				//
				// // 头像
				// ImageLoader.getInstance().displayImage(
				// Constants.BadiDownImgUrl
				// + "/"
				// + mailModels.get(position).getCons2().getClub()
				// .getLogo(), holder.head, options);
				// holder.name.setText(""
				// + mailModels.get(position).getCons2().getClub()
				// .getName());
				// 删除站内信的按钮
				if (isClickIndexButton == true) {
					holder.deletebtn.setVisibility(View.VISIBLE);
					holder.deletebtn
							.setOnClickListener(new View.OnClickListener() {

								@Override
								public void onClick(View v) {
									pos_ = position;
									delete(Utils.getUid(getActivity()),
											mailModels.get(position).getId(),
											mailModels.get(position).getType(),
											rank, handler);
								}
							});
					//    
				} else {
					holder.deletebtn.setVisibility(View.INVISIBLE);
					holder.deletebtn
							.setOnClickListener(new View.OnClickListener() {

								@Override
								public void onClick(View v) {
								}
							});
				}
				return convertView;

			}
		}

		/**
		 * 用户显示的站内信列表（必须是自己看自己的）
		 * 
		 * @param $uid
		 *            //登录用户ID 测试uid=1// 这个不用传
		 * @param $listType
		 *            //all:全部 usercontact：用户联系 clubnotice：俱乐部通知
		 *            contactclub：联系俱乐部
		 * @param $page
		 *            ;//第几页
		 * @param $pageNum
		 *            ;//每页显示条数 http://127.0.0.1:8080/badibadi/App/inform/mail
		 */
		public void mail(final String listType, final int page) {
			list = new ArrayList<MailModel>();
			MyThreadTool.fixedThreadPool.execute(new Runnable() {
				@Override
				public void run() {
					Map<String, Object> map = new HashMap<String, Object>();
					map.put("uid", Utils.getUid(getActivity()));
					map.put("listType", listType);
					map.put("page", "" + page);
					map.put("pageNum", "" + pageNum);
					String content = Utils.sendRequest(map, Constants.BadiUrl_1
							+ "inform/mail");
					// String content = Utils.getRequest(Constants.BadiUrl
					// + "record_info?rid=" + rid);
					if (content != null) {
						Results results = Utils.checkResult_NNN(getActivity(),
								content);
						//    ("记录的详细数据是:" + content);
//						   
						if (results != null
								&& !results.getRetmsg().equals("null")
								&& results.isRet()) {
//							   
							try {
								list = JSONUtils.getListByJsonString(
										results.getRetmsg(), MailModel.class);
								handler.sendEmptyMessage(2);
							} catch (Exception e) {
								   
							}
						} else {
							handler.sendEmptyMessage(3);
						}
					} else {

						handler.sendEmptyMessage(1);
					}
				}
			});
		}

	}

	static class ViewHolder {
		public LinearLayout jmp;
		public ImageView youjiantou;
		public ImageView logo;
		public TextView name;
		public TextView time;
		public TextView zxOrhy;
		public TextView title;
		public TextView nickName;
		public ImageView head;
		Button deletebtn;
	}

	public void setOnIndexClistener(IndexButtonState mButtonState) {
		indexButtonState = mButtonState;
		switch (add_in) {
		// case 0:
		// indexButtonState.indexButtonSelect(isClickIndexButton);
		// frag0.x1Adapter.notifyDataSetInvalidated();
		// break;
		case 0:
			indexButtonState.indexButtonSelect(isClickIndexButton);
			frag1.x1Adapter.notifyDataSetInvalidated();
			break;
		case 1:
			indexButtonState.indexButtonSelect(isClickIndexButton);
			frag2.x1Adapter.notifyDataSetInvalidated();
			break;
		case 2:
			indexButtonState.indexButtonSelect(isClickIndexButton);
			frag3.x1Adapter.notifyDataSetInvalidated();
			break;
		}

	}

	/**
	 * 删除站内信操作---POST
	 * 
	 * @param $uid
	 *            ---登录用户ID
	 * @param $zhanneiId
	 *            ----站内信ID
	 * @param $type
	 *            ----删除的站内信类型 zhannei_usercontact：用户联系 zhannei_clubnotice：俱乐部通知
	 *            zhannei_contactclub：联系俱乐部
	 * @param $rank
	 *            ---操作者的身份 asker：问方 answerer：答方 注意：当为“用户联系”才有该参数
	 */
	public void delete(String uid, String zhanneiId, String type, String rank,
			android.os.Handler handler) {
		Utils.showPrgress(getActivity());
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("zhanneiId", zhanneiId);
		map.put("type", type);
		if (type.equals("zhannei_usercontact")) {
			map.put("rank", rank);
		}
		CommonUtils.CommomPostfunction(getActivity(), Constants.BadiUrl_1 + "/"
				+ "inform/delete", map, handler, 1, 4, 5, 6);
	}

	public interface IndexButtonState {
		boolean indexButtonSelect(boolean isSelectIndexBtn);
	}
}
